#ifndef _HORIZONTALSCROLLVIEW_LULYUI_H_
#define _HORIZONTALSCROLLVIEW_LULYUI_H_
#include <unordered_set>

#include "Layout.h"
#include "UIObject.h"
//水平滚动视图
class HorizontalScrollView : public UIObject {
 public:
  enum class Alignment { Left, Right };

 private:
  //有一个布局
  //他的WidthMode恒为FIT
  // Arrangement恒为Horizontal
  Layout* layout;

  Alignment alignment;

  //这是与layout横坐标最大的差值
  //用来表示滚动的范围
  //是一个0/正值
  int maxDeltaX = 0;
  int current_deltaX = 0;

  //每根在范围内按下手指的ID
  std::unordered_set<int> fingerIds;

  void event() override;
  void drawArea(const Rect& area) override;
  void init() override;

 public:
  HorizontalScrollView(std::string uiObjectId,
                       HorizontalScrollView::Alignment alignment =
                           HorizontalScrollView::Alignment::Left);


  //子对象是添加到layout里面的
  void addChild(UIObject* uiobject) override { layout->addChild(uiobject); }

  //重写setWidthMode
  void setHeightMode(UIObject::WHMode heightmode) override {
    UIObject::heightMode = heightMode;
    layout->setHeightMode(heightMode);  // layout的heightmode也可以改变
  }
  // setWidthMode和UIObject一样，不需要重写
};
#endif